using System;
using System.Collections.Generic;
using System.Text;
using System.Security;
using System.ComponentModel;

namespace InfiniTec.Security
{
    /// <summary>
    /// Contains information about the user account being impersonated.
    /// </summary>
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable")]
    public class AcquireCredentialEventArgs: CancelEventArgs
    {
        string _Username;
        SecureString _Password;
        string _TargetName;
        int _AttemptCount;

        /// <summary>
        /// Gets or sets the username used for the request. If <see cref="CancelEventArgs.Cancel"/> is
        /// set to false, this property must be set to the username used for the <see cref="ImpersonationScope"/>.
        /// </summary>
        public string Username { get { return _Username; } set { _Username = value; } }
        /// <summary>
        /// Gets or sets the password used for the request. If <see cref="CancelEventArgs.Cancel"/> is
        /// set to false, this property must be set to the password used for the <see cref="ImpersonationScope"/>.
        /// </summary>
        public SecureString Password { get { return _Password; } set { _Password = value; } }
        /// <summary>
        /// Gets the target name for the current request.
        /// </summary>
        public string TargetName { get { return _TargetName; } }
        /// <summary>
        /// Returns the retry count for the current request.
        /// </summary>
        public int AttemptCount { get { return _AttemptCount; } }

        /// <summary>
        /// Creates a new instance of this class.
        /// </summary>
        /// <param name="targetName">The target name for the request.</param>
        /// <param name="attemptCount">The retry count of the request.</param>
        internal AcquireCredentialEventArgs(string targetName, int attemptCount): base(false)
        {
            _TargetName = targetName;
            _AttemptCount = attemptCount;
            _Password = new SecureString();
        }
    }
}
